package thread.basepackage.t8;

/**
 * println源码里用到了Synchronized
 * <p>
 * Created by cuihao on 2017/11/29.
 */
public class Run {
    public static void main(String[] args) {
        try {
            MyThread thread = new MyThread();
            thread.start();
            Thread.sleep(1000);
            thread.suspend();
            System.out.println("main end 不会打印输出");

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

/*
ptintln()源码如下：

    public void println(String x) {
        synchronize (this) {
            print(x);
            newLine();
        }
    }

thread suspend后会把 MyThread中的
System.out.println("运行了"+i);锁定
所以Run里的 System.out.println("main end 不会打印输出");不会执行



 */
